<div id="edit_group_page">
    <div id="edit_group_wrapper">
        <p id="p_edit_group">Edit <em><?php echo $group_name; ?></em></p>
        <?php 
            $group_id = $groups['group_id']; 
            echo form_open("groups_c/edit_group/$group_id", array('id' => 'edit_group_form'));
        
            echo "<div id='error_message_area'>".$error_message."</div>"; ?>
        
        <label for="groupName" id="lblGroupName">Group Name</label>
        <input type="text" name="groupName" id="edit_group_name" value="<?php echo $group_name; ?>"/>
        
        <label for="groupDesc" id="lblGroupDesc">Group Description</label>
        <textarea name="groupDesc" id="edit_group_desc"><?php echo $group_desc; ?></textarea>
        
        <p id="p_allow_subscribable">
            <?php
                if($isSubs == true) {
                    echo "<input type='checkbox' name='isSubs' value='make_subscribable' id='create_group_subscribe' checked/>";
                }
                if($isSubs == false) {
                    echo "<input type='checkbox' name='isSubs' value='make_subscribable' id='create_group_subscribe' />";
                }
            ?>
            Allow all registered users to subscribe to this group</p>
            
         <div id="available_admins_area">
            <p id="admins_header">Group Admins</p>
            <p id="p_choosePeople">Choose people who can post in this group: <strong>(at least one</strong>)</p>
            
            <p id="p_find">Display
                <select id="display_method_select" name="display_method_select">
                    <option value="All">Admins and Authors</option>
                    <option value="Authors">Authors Only</option>
                    <option value="Admins">Site Admins only</option>
                    <?php
                        foreach($all_departments as $dep) {
                            $dep_name = $dep['department'];
                            echo "<option>all from $dep_name</option>";
                        }
                    ?>
                </select>
                <button id="btn_go" name="btn_go">Go</button>
            </p>

        <?php
            for($i = 0; $i < count($available_emps); $i++) {
              $id = $available_emps[$i]['user_id'];
              $name = $available_emps[$i]['fname'].' '.$available_emps[$i]['lname'];
              
              if(in_array($id, $admins)) {
                  if($role_id == 2 || $rolename == 'author') {
                      echo "<p><input type='checkbox' name='available_emps[]' class='available_inst' value=$id checked='checked' disabled /> $name</p>";
                  }
                  else if($role_id == 1 || $rolename == 'admin') {
                      echo "<p><input type='checkbox' name='available_emps[]' class='available_inst' value=$id checked='checked' /> $name</p>";
                  }
              }
              else {
                  if($role_id == 2 || $rolename == 'author') {
                    echo "<p><input type='checkbox' name='available_emps[]' class='available_inst' value=$id disabled /> $name</p>";
                  }
                  else if($role_id == 1 || $rolename == 'admin') {
                      echo "<p><input type='checkbox' name='available_emps[]' class='available_inst' value=$id /> $name</p>";
                  }
                
              }
            }
            
           ?>
         </div>
             <input type="submit" onclick="enableBoxes()" name="submit2" value="Update Group Details" id="edit_group_save" />
        <input type="button" id="btn_cancel" value="Cancel" onclick="window.location='<?php echo base_url() ?>groups';" />
        <?php echo form_close(); ?>
    </div>
</div>


<script>
    function enableBoxes() {
        var boxes = document.getElementsByClassName('available_inst');
        for (var i = 0; i < boxes.length; i++)
        {
          boxes[i].disabled = false;
        }
    }
</script>
